# Author:xiaoma
# date：1014-week07

# 1、运行程序后，让用户输入支付宝余额，然后打印我们的商品列表给用户。
money = input("请输入您的余额")
goods = [('玩具车', 100), ('洗发水', 200), ('护发素', 300)]
money = int(money)
user_shop_list = []
while True:
    for index, item in enumerate(goods):
        print(index, item)

    # 2、让用户输入商品编号进行商品的购买。
    buy = input("请输入您想购买的物品,如想退出请输入'N'")
    if buy.isdigit():
        buy = int(buy)
        if buy >= 0 and buy < len(goods):
            print("您想购买的洗面奶￥100")
            p_item = goods[buy]

            # 3.用户选择商品后，检查用户的余额是否够，若够则直接扣款，不够则提醒用户
            if p_item[1] <= money:
                user_shop_list.append(p_item)
                money -= p_item[1]
                print("您选购商品的金额是%s，您的余额还有%s" %(user_shop_list,money))
            else:
                print("您的支付宝余额不足")
    # 4、用户可以随时退出购买，推出时打印用户己购买的商品和支付宝余额。
    elif buy == "N":
        print("---------- 购物清单 ----------")
        for i in user_shop_list:
            print(i)
            print("您的余额还有%s" %(money))
        break

    else:
        print("您输入的商品不存在或者没有输入正确的数字")






# goods = [["1001","python课本","88"],["1002","洗面奶","100"],["1003","洗发水","200"]]
# user_shop_list = []
# 支付宝余额 = input("请输入您的余额")
#
# info = '''------goods list------
# %s
# %s
# %s
# '''%(goods[0],goods[1],goods[2])
# print(info)
# user_input_ID = input("请输入商品ID：")
# for good in goods:
#     print(good)
#     # 判断商品id是否正常
#     if user_input_ID == good[0]:
#         if int(good[2]) < int(支付宝余额):
#             user_shop_list.append(good)
#             break
#     else:
#         print("您输入的商品信息有问题")




